import React, { useState } from 'react'
import Nav from '@/pages/components/nav'
import api from '@/api'
import BlogList from './components/BlogList'
import './index.less'
export default function Home(props) {
    const [list, setList] = useState([])

    const userDataStr = window.localStorage.getItem('userData')
    const userData = userDataStr ? JSON.parse(userDataStr) : {}
    const update = (tag) => {
        // 通过typeList 掉接口
        api.getBlog({ pageIndex: 1, pageSize: 5, tag, user_id: userData.id }).then(res => {
            if (res.success) {
                setList(res.data)
            }
        })
    }
    return (
        <div>
            <Nav update={update} />
            <BlogList {...props} list={list} />

        </div>
    )
}
